﻿ #define_CRT_SECURE_NO_WARNINGS 1	
     贪心
     7. 最⻓连续递增序列（easy）
     8. 买卖股票的最佳时机（easy）
     9. 买卖股票的最佳时机 Ⅱ（medium）
     7. 最⻓连续递增序列（easy）
     https ://leetcode.cn/problems/longest-continuous-increasing-subsequence/description/

 class Solution {
 public:
     int findLengthOfLCIS(vector<int>& nums) {
         int ret = 0, n = nums.size();
         //区间为[)，左闭右开
         for (int left = 0; left < n;)
         {
             int right = left + 1;
             while (right<n && nums[right]>nums[right - 1])right++;
             ret = max(ret, right - left);
             left = right;
         }
         return ret;
     }
 };
 8. 买卖股票的最佳时机（easy）
     https ://leetcode.cn/problems/best-time-to-buy-and-sell-stock/

 class Solution {
 public:
     int maxProfit(vector<int>& prices) {
         //区间遍历做贪心优化，固定售出点，找前缀区间的最小和（贪心优化）
         int ret = 0;
         for (int i = 0, prefix_min = INT_MAX; i < prices.size(); i++)
         {
             ret = max(ret, prices[i] - prefix_min);
             prefix_min = min(prefix_min, prices[i]);
         }
         return ret;
     }
 };
 9. 买卖股票的最佳时机 Ⅱ（medium）
     https ://leetcode.cn/problems/best-time-to-buy-and-sell-stock-ii/description/

 class Solution {
 public:
     int maxProfit(vector<int>& prices) {
         //点线图连接起来，贪心策略为找递增直线
         int ret = 0;
         int n = prices.size();
         for (int left = 0; left < n;)
         {
             int right = left;
             while (right + 1 < prices.size() && prices[right + 1] > prices[right])right++;
             ret += prices[right] - prices[left];
             left = right + 1;
         }
         return ret;
     }
 };